/*
 * @Title: 中奖记录
 * @Author: JSL
 * @Date:   2018-12-20
 * @Last Modified by:   JSL
 * @Last Modified time: 2018-12-20
 */
var dataInfo = {},
  template = {
    init: function() {
      dataInfo.init = new Vue({
        el: '#app',
        data: {
          listData: [],
          listLength: 1,
          loading: false,
          isLoading: false,
          finished: false,
          page: 1,
          showNum: 0
        },
        methods: {
          onLoad: function() {
            this.listLength > this.listData.length ? this.getList() : '';
            this.loading = false;
            this.isLoading = false;
          },
          onRefresh: function() { //下拉刷新
            this.page = 1;
            this.listData = [];
            dataInfo.init.getList();
            setTimeout(function() {
              dataInfo.init.loading = false;
              dataInfo.init.isLoading = false;
            }, 500);
          },
          getList: function() {
            ajaxTemplate(addressTest + SERVICE.queryUserSignRecord, function(data) {
              console.log(data);
              if (data.tag == 0) {
                dataInfo.init.listLength = data.data.total;
                dataInfo.init.listData = dataInfo.init.listData.concat(data.data.result);
                dataInfo.init.showNum = dataInfo.init.listData.length;
              } else {
                dataInfo.init.$toast(data.errMsg);
                if (data.errMsg == '请求参数[access_token]不能为空！') {
                  jumpLogin();
                };
              };
            }, {
              userId: userId,
              page: this.page++,
              limit: 10
            });
          },
          toNext: function(item) {
            if (item.status == 2) { //填地址 181220
              setCookie('zmtMallOrder', escape(JSON.stringify({
                id: item.id,
                remarks: item.barcode
              })), 30);
              location.href = '../html/orderPrize.html';
            } else if (item.status == 3) { //订单详情
              location.href = '../html/orderDetails.html?orderId=' + item.remarks;
            };
          },
        },
      });
      //初始化函数
    },
  };
template.init();
